home *** CD-ROM | disk | FTP | other *** search
- Path: rose_ip167.efn.org!peterf
- From: peterf@gears.efn.org (Peter F.)
- Newsgroups: comp.lang.c++
- Subject: Binaries
- Date: Tue, 2 Jan 1996 23:18:34
- Organization: Southern Oregon Unified Networking District (SOUND)
- Message-ID: <peterf.58.00174FE2@gears.efn.org>
- NNTP-Posting-Host: rose_ip167.efn.org
- X-Newsreader: Trumpet for Windows [Version 1.0 Rev A]
-
- Dear Friends,
-
- I have been working on a c++ program, where the goal is to imitate the dos
- copy command. I have been writing this program, and it works eccept for one
- small thing. When I read a file, say 29,300 bytes and then want to output
- that file to a new directory, the files always come out 1 byte larger (ex.
- 29,301). I dont know where the extra byte is coming from? Here is the code
- and maybe you could find the problem....
-
- #include <stdio.h>
-
- void main(void)
- {
- FILE *in, *out;
-
- if ((in = fopen("C:\\car.pcx", "rb"))== NULL)
- {
- fprintf(stderr, "Cannot open input file.\n");
- }
-
- if ((out = fopen("C:\\temp\\car.pcx", "wb"))== NULL)
- {
- fprintf(stderr, "Cannot open output file.\n");
- }
-
- while (!feof(in))
- { fputc(fgetc(in), out); }
-
- fclose(in);
- fclose(out);
- }
-
- I compiled this code, and when I tried to view the car.pcx file in the temp
- dir. it was the same image, but the colors had changed. I am worried with
- this extra byte that it may mess up .exe or .dll files when copied.
- Also if anyone knows how to access Dos commands like copy or move from C++
- this could help also. I use BC++ 3.1.
-
- P.S. -- Anyone know how the copy command works, like how it keeps the same
- date, time, file size, of the target file you copied from.
-
- Thanks,
-
- Peter Felten
-
- peterf@gears.efn.org
-